<template>
  <div class="newsinfo-container">
    <h3 class="title">{{newsObj.title}}</h3>
    <p class="subtitle">
      <span>发表时间:{{newsObj.add_time}}</span>
      <span>点击: {{newsObj.click}}次</span>
    </p>
    <hr />
    <div class="content" v-html="newsObj.content"></div>
    <comment-box :id='id'></comment-box>
  </div>
</template>
<script>
import { Toast } from "mint-ui";
import comment from "../subcomponents/comment.vue";
export default {
  data() {
    return {
      id: this.$route.params.id,
      newsObj: {}
    };
  },
  created() {
    this.getInfoList();
    console.log(this.id);
  },
  methods: {
    getInfoList() {
      this.$http.get("../../../static/infolist.json").then(result => {
        let response = result.body.data.message;
        response.forEach((val, index, val_arr) => {
          if (val.id == this.$route.params.id) {
            // console.log(val);
            this.newsObj = val;
            return;
          }
        });
        // console.log(response);
        // console.log(this.$route.params.id);
        // console.log(this.newsObj);

        // if (result.body.status === 0) {
        //   // this.newsList = result.body.data.newsList;
        // } else {
        //   Toast({
        //     message: "轮播图加载失败...",
        //     position: "middle",
        //     duration: 3000,
        //     iconClass: "glyphicon glyphicon-remove",
        //     className: "myicon"
        //   });
        // }
      });
    }
  },
  components: {
    "comment-box": comment
  }
};
</script>
<style lang="scss" scoped>
.newsinfo-container {
  padding: 0 4px;
  .title {
    font-size: 16px;
    text-align: center;
    margin: 15px 0;
    color: red;
  }
  .subtitle {
    font-size: 13px;
    color: #226aff;
    display: flex;
    justify-content: space-between;
  }
  .content {
    .content {
      img {
        width: 100%;
      }
    }
  }
}
</style>